
define(['./custom/widgets/js/yufpSelectParam.js'],
	function (require, exports) {



		exports.ready = function (hashCode, data, cite) {

			yufp.lookup.reg('USE_TASK_TYPE,USE_TASK_STATE,USE_TASK_TRIGGER_TYPE');
			yufp.custom.vue({
				el: cite.el,
				data: function () {
					var _this = this;
					/*定义校验规则，只能填字母数字 下划线*/
					var valiCodes = function (rule, value, callback) {
						var reg = /^[0-9a-zA-Z_]{1,}$/;
						if (value && reg.test(value)) {
							if (value.length > 64) {
								callback(new Error('长度不能大于64位'));
							} else {
								callback();
							}
						} else if (value && !reg.test(value)) {
							callback(new Error('能填字母、数字和下划线'));
						} else {
							callback();
						}
					};
					/*定义只能输入8位有效时间*/
					var valiDateWeek = function (rule, value, callback) {
						var reg = /^(\d{4})(\d{2})(\d{2})$/; //yyyymmdd
						var reg1 = /\{\#.*?\#\}/g
						if (value && (reg.test(value) || reg1.test(value))) {
							callback();
						} else {
							callback(new Error('只能为yyyyMMdd格式或选择参数'));
						}
					};

					return {
						editDowIndex:0,
						viewOnly:false,
						tbHeight:'0',
						//导入导出的data  start
						importFnButton: !yufp.session.checkCtrl('importFn'),
						exportFnButton: !yufp.session.checkCtrl('exportFn'),
						upLoadDialogVisible: false,//是否显示导入页面
						upLoadUrl: yufp.service.getUrl({ url: "api/file/provider/uploadfile" }),//导入的url
						appUploadDatas: [],//文件列表
						showHeader: false,//是否显示错误表头
						errshow: false,//显示导入的错误信息，默认不显示
						excelloading: false,//导入的loading
						errdata: [],//导入的错误信息
						multipleFalg: false,//是否允许多文件
						//导入导出的data  end 


						searchFormdata: {},
						appNameDisabled: false,
						addFnButton: !yufp.session.checkCtrl('addFn'),
						updateFnButton: !yufp.session.checkCtrl('updateFn'),
						deleteFnButton: !yufp.session.checkCtrl('deleteFn'),
						addClassFnButton: !yufp.session.checkCtrl('addClassFn'),
						updateClassFnButton: !yufp.session.checkCtrl('updateClassFn'),
						deleteClassFnButton: !yufp.session.checkCtrl('deleteClassFn'),
						batchSaveFnButton: !yufp.session.checkCtrl('batchSave'),
						startOffFnButton: !yufp.session.checkCtrl('startOffFn'),
						startOnFnButton: !yufp.session.checkCtrl('startOnFn'),

						treeDataUrl: "api/use/plats/taskSchedule/queryTreeList",
						queryRefDataList: "api/use/plats/taskSchedule/queryRefDataList",
						dataUrl: 'api/use/plats/taskSchedule/queryList',
						//triggerDataUrl: 'api/use/plats/trigger/queryUttList',
						calendarDataUrl: "api/use/plats/calendar/queryCalendarList",
						async: false,
						height: yufp.frame.size().height - 147,
						viewTitleArrry: ['任务信息添加', '任务信息修改', '任务信息查看'],
						viewTitle: '',
						viewClassTitleArrry: ['添加任务目录信息', '修改任务目录信息'],
						viewClassTitle: "",
						isNodeLeaf: false,
						isClassaddFlag: false,
						currentClickNode: {},
						classDialogVisible: false,
						dialogVisible: false,
						addFlag: false,
						updateFlag: false,
						isReadOnly: false,
						isTrigger: false,
						activeTabName: "taskInfo",
						formdata: {},
						groupCodeOptions: [],
						calendarCodeOptions: [],
						triggerOptions: [],
						chooseFolderDialogVisible: false,
						defaultFolderKey: [],
						paramDatas: [{ paramCode: "a", paramName: "b", paramValue: "c", remark: "add" }],
						folderRoot: "",
						folderHeight: 300,
						cancelBtnShow: true,
						saveBtnShow: true,
						triggerRules: [{ required: true, message: '必填项', trigger: 'blur' }],
						weekrules: [
							{ required: true, message: '必填项', trigger: 'blur' },
							{ validator: valiDateWeek, trigger: 'blur' }
						],
						rulesCode: [
							{ validator: valiCodes, trigger: 'blur' }
						],
						chooseCommonParamDialogVisible: false,
						triggerParam: {},
						nodeTemp: {},
						isView: false,
						commParamDataUrl: 'api/use/plats/paramValue/queryMacrosList',
						commParamBase: { condition: {} },
						commParamFieldColumns: [
							{ label: '参数名称', prop: 'paramName', resizable: true },
							{ label: '参数代码', prop: 'paramCode', resizable: true }
						],
						commParamFieldDatas: [{
							placeholder: '参数名称',
							field: 'paramName',
							type: 'input'
						}],
						commParamButtons: [{
							label: '搜索',
							op: 'submit',
							type: 'primary',
							click: function (model, valid) {
								if (valid) {
									if (_this.addFlag) {
										model.appCode = _this.currentClickNode.appCode;
									} else {
										if(_this.viewOnly){
											model.appCode = _this.nodeTemp.appCode;
										}else{
											model.appCode = _this.$refs.refTable.selections[0].appCode;								
										}
									}

									var param = { condition: JSON.stringify(model) };
									_this.$refs.commParamTableRef.remoteData(param);
								}
							}
						},
						{
							label: '确定', op: 'submit', type: 'primary',
							click: function (model, valid) {
								_this.selectCommParamValue();
							}
						}],

						classFields: [{
							columnCount: 2,
							fields: [
								{
									field: 'appCode',
									label: '所属应用系统编号:',
									hidden: true
								},
								{
									field: 'appName',
									label: '所属应用系统:',
									disabled: true
								},
								{
									field: 'parentFolder',
									label: '上级目录名称:',
									hidden: true
								},
								{
									field: 'parentFolderName',
									label: '上级目录名称:',
									disabled: true
								},
								{
									field: 'folderCode',
									maxlength: 64,
									label: '目录代码:',
									rules: [
										{ validator: valiCodes, trigger: 'blur' }
									]
								},
								{
									field: 'folderName',
									label: '目录名称:',
									maxlength: 120,
									rules: [{ required: true, message: '必填项', trigger: 'blur' },
									{ max: 120, message: '输入值过长', trigger: 'blur' }]
								},

							]

						}, {
							columnCount: 1,
							fields: [

								{
									field: 'remark',
									label: '备注:',
									type: "textarea",
									rows: 3,
									maxlength: 240,
									rules: [{ max: 240, message: '输入值过长', trigger: 'blur' }]
								}
							]
						}],

						classButtons: [
							{
								label: '取消', hidden: false, click: function (model) {
									_this.cancelClassFn();
								}
							},
							{
								label: '保存', type: 'primary', hidden: false, op: 'submit', click: function (model, valid) {
									_this.saveClassCodeFn();
								}
							}
						],
						tableColumns: [
							{ label: '编号', type: "index" },
							{ label: '系统名称', prop: 'appName', hidden: false },
							{ label: '任务路径', prop: 'folderPath' },
							{
								label: '任务名称',
								prop: 'taskName',
								template: function () {
									return '<template scope="scope">\
                               <a style="text-decoration:underline;color:#636CE4 " href="javascipt:void(0);"  @click="_$event(\'custom-detail-click\', scope.row)">{{ scope.row.taskName }}</a>\
                           </template>';
								}
							},
							{ label: '任务类型', prop: 'triggerType', dataCode: 'USE_TASK_TRIGGER_TYPE' },
							{ label: '工作日历', prop: 'calendarName' },
							{ label: '生效日期', prop: 'effectDate', },
							{ label: '失效日期', prop: 'expireDate', },
							{ label: '任务状态', prop: 'validFlag', dataCode: 'USE_TASK_STATE' },
							{ label: '备注', prop: 'remark' }
						],
						// 触发器url
						triggerDataUrl: 'api/use/plats/trigger/queryList',
						// 触发器选择
						chooseTriggerDialogVisible: false,
						// 触发器选择-查询条件
						triggerFieldDatas: [{
							placeholder: '触发器名称',
							field: 'timerName',
							type: 'input'
						}],
						// 触发器选择-按钮
						triggerButtons: [{
							label: '搜索',
							op: 'submit',
							type: 'primary',
							click: function (model, valid) {
								if (valid) {
									if (_this.addFlag) {
										model.appCode = _this.currentClickNode.appCode;
									} else {
										model.appCode = _this.$refs.refTable.selections[0].appCode;
									}
									var param = { condition: JSON.stringify(model) };
									_this.$refs.triggerTableRef.remoteData(param);
								}
							}
						},
						{
							label: '确定', op: 'submit', type: 'primary',
							click: function (model, valid) {
								_this.selectTriggerValue();
							}
						},
						{
							label: '人工触发', op: 'submit',
							click: function (model, valid) {
								_this.formdata.triggerNm = '人工触发';
								_this.formdata.triggerId = '-';
								_this.chooseTriggerDialogVisible = false;
							}
						}],
						// 触发器选择-列表字段
						triggerFieldColumns: [
							{ label: '触发器编号', prop: 'timerCode', resizable: true },
							{ label: '触发器名称', prop: 'timerName', resizable: true },
							{ label: '开始日期', prop: 'effectDate', resizable: true },
							{ label: '结束日期', prop: 'expireDate', resizable: true },
							{ label: '表达式', prop: 'expression', resizable: true },
							{ label: '备注', prop: 'remark', resizable: true }
						],
						// 展示内置时点选择标志
						showInsideCycleTime: false,
						InSideFlagOptions: [
							{ key: 'Y', value: '是' },
							{ key: 'N', value: '否' }
						],
						// 确认屏蔽
						showConfim: true,
						exportLoading: false
					};
				},
				mounted:function(){
					var _this = this;
					//测试
					_this.$nextTick(function(){
							var tableBox = _this.$refs.tableBox;
							let a = tableBox.getBoundingClientRect().top + 28;
							var theight = `calc(100vh - ${a}px - 64px)`;
							_this.tbHeight = theight;		
					});
				},
				methods: {
					tableRowClassName({ row, rowIndex }) {
						//把每一行的索引放入row
						row.index = rowIndex;
					  },

					selectFn:function(data,value){
						var selection=data;
						 //这里需要找到第几个在修改
						 let clickIdex = this.editDowIndex || 0;
						 this.$refs.refparamstab.data[clickIdex].paramName = data[0].paramName;
						 this.$refs.refparamstab.data[clickIdex].paramCode = data[0].paramCode;

					},

					//点击导出模板操作
					exportDemo: function () {
						var _this = this;
						var condition = { busiType: "TASK" };
						var search = _this.searchFormdata;
						yufp.util.download("api/use/excel/exportTempExcel?condition="
							+ encodeURI(JSON.stringify(condition)));
					},
					// 使用内置时点选择处理
					changeInSide: function (value, text) {
						var _this = this;
						if (value === 'Y') {
							//this.showInsideCycleTime = true;
							if (_this.showConfim) {
								_this.$confirm('若设置内置时点,则周期时点等于内置时点时任务才运行,且任务运行完成后自动步进内置时点', '提示', {
									confirmButtonText: '确定',
									cancelButtonText: '取消',
									type: 'warning',
									duration: 6000,
									center: true,
									callback: function (action) {
										if (action === 'confirm') {
											_this.showInsideCycleTime = true;
										} else {
											_this.InSideFlag = "N";
										}
									}
								});
							} else {
								_this.showConfim = true;
								_this.showInsideCycleTime = true;
							}
						} else {
							_this.showConfim = true;
							_this.showInsideCycleTime = false;
							if (_this.formdata.insideCycleTime) {
								_this.formdata.insideCycleTime = "";
							}
						}
					},
					//点击导出操作
					exportFlowFn: function () {
						var _this = this;
						var condition = { busiType: "TASK" };
						var search = _this.searchFormdata;
						condition.appName = search.appName;
						condition.taskName = search.taskName;
						_this.exportLoading = true;
					   var selections = _this.$refs.refTable.selections || [];
                           if (selections.length > 0) {
                              var params =[];
                               for(var i=0;i<selections.length ;i++){
                                var object={"appCode":selections[i].appCode,"groupCode":selections[i].groupCode,
                                "taskId":selections[i].taskId  };
                                params.push(object);
                               }

                                condition.dataList = params;
                         }

				    	yufp.service.request({
						  method: 'POST',
						  url: '/api/use/excel/exportExcelForWeb',
					    	data: {condition: condition},
					    	callback: function (code, message, response) {
					        	_this.exportLoading = false;
					        	if (response.code === 0) {
				  		        	yufp.util.download("api/use/excel/downLoadExcel?filePath=" + response.data.allFilePath + "&fileName=" + response.data.fileName);
					        	} else {
						        	this.$message.error('导出失败');
					        	}
					    	}
				    	});
					},
					importFlowFn: function () { //点击导入操作
						this.upLoadDialogVisible = true;
						this.$nextTick(function () {
							this.$refs['my-upload'].clearFiles();
							this.errshow = false;
							this.errdata = [];
						})
					},
					/**
					 *导入前的检验操作操作
					 */
					checkUpload: function (file) {
						//alert(file);

						var isLt10M = file.size / 1024 / 1024 < 100;
						if (!isLt10M) {
							this.$message.error('上传文件大小不能超过 100MB!');
						}
						var index = file.name.lastIndexOf('.');
						var ext = file.name.substr(index + 1);

						var suffixValid = ('xlsx' === ext || 'xls' === ext);
						if (!suffixValid) {
							this.$message.error('上传文件的格式必须为excel格式');
							return false;
						}
						return isLt10M && suffixValid;
					},
					successUpload: function (response, file, fileList) { //导入成功后执行
						/*	console.log('上传成功！')
							this.$refs['my-upload'].clearFiles();*/


						const _this = this;
						const param = {};
						/* 					_this.$loading({
												target:'.load-target',
												body:true
											}) */
						_this.excelloading = true;
						param.busiType = "TASK";
						param.excelUpLoadFile = response.data;
						yufp.service.request({
							method: 'POST',
							url: '/api/use/excel/importExcel',
							data: param,
							timeout: 1800000,
							callback: function (code, message, response) {
								_this.excelloading = false;
								if (response.code == 0 && response.data.errorInfos.length == 0 && response.data.impStatus != '失败') {
									_this.$refs['my-upload'].clearFiles();
									_this.errshow = false;
									_this.errdata = [];
									_this.upLoadDialogVisible = false;
									_this.$message('导入成功!');
									//同时重新查询列表

									var param = {
										condition: JSON.stringify(_this.searchFormdata)
									};
									_this.$refs.refTable.remoteData(param);

								} else {
									_this.errshow = true;
									_this.$refs['my-upload'].clearFiles();
									_this.errdata = [];
									if (response.data && response.data.errorInfos.length > 0 && response.data.errorInfos[0].errorList) {
										response.data.errorInfos[0].errorList.map(function (item, index) {
											_this.errdata.push({
												"errMsg": item
											})
											console.log('errdata', _this.errdata)
										})
									} else {
										_this.errdata.push({
											"errMsg": response.message
										})
									}

								}
							}
						});
					},

					// 显示loading
					showLoading: function () {
						this.anyscLoading = this.$loading({ fullscreen: true })
					},
					// 关闭loading
					closeLoading: function () {
						this.anyscLoading.close();
					},

					paramClick: function (row, event, column, index) {
						this.nodeTemp.paramSelectValue = row.paramValue;
						this.editDowIndex = row.index;
					},

					nodeClickFn: function (nodeData, node, self) {
						var _this = this;
						_this.currentClickNode = nodeData;
						let appCode = "";
						let folderCode = "";

						if (nodeData.nodeType != 'R') {
							_this.isNodeLeaf = true;
							_this.tableColumns[1].hidden = true;
							_this.appNameDisabled = true;
							_this.searchFormdata.appName = nodeData.appName;
							appCode = nodeData.appCode;
							_this.nodeTemp.appCode = nodeData.appCode;
							if (nodeData.nodeType === 'C') {
								folderCode = nodeData.currentNodeId
							}

						} else {
							_this.nodeTemp.appCode = nodeData.appCode;
							_this.isNodeLeaf = false;
							_this.appNameDisabled = false;
							_this.searchFormdata.appName = '';
							_this.tableColumns[1].hidden = false;
						}


						_this.searchFormdata.appCode = appCode;
						_this.searchFormdata.folderCode = folderCode;
						var param = { condition: JSON.stringify(_this.searchFormdata) };
						_this.$refs.refTable.remoteData(param);

					},

					createTreeFn: function () {
						var _this = this;
						if (_this.currentClickNode == null
							|| _this.currentClickNode.nodeType == null
							|| _this.currentClickNode.nodeType === 'R') {
							_this.$message("请选择一个应用系统或目录");
							return;
						}
						_this.classDialogVisible = true;
						_this.viewClassTitle = _this.viewClassTitleArrry[0];
						_this.$set(_this.classFields[0].fields[4], 'readonly', false);
						_this.isClassaddFlag = true;
						_this.$nextTick(function () {
							_this.$refs.refClassForm.switch(_this.classFields[0].fields[4].field, 'disabled', false);
							_this.$refs.refClassForm.resetFields();
							_this.$refs.refClassForm.formModel.appCode = _this.currentClickNode.appCode;
							_this.$refs.refClassForm.formModel.appName = _this.currentClickNode.appName;

							if (_this.currentClickNode.nodeType === 'A') {
								_this.$refs.refClassForm.formModel.parentFolder = " ";
								_this.$refs.refClassForm.formModel.parentFolderName = "事件分层主目录";
							} else {
								_this.$refs.refClassForm.formModel.parentFolder = _this.currentClickNode.currentNodeId;
								_this.$refs.refClassForm.formModel.parentFolderName = _this.currentClickNode.currentNodeName;
							}


						});

					},
					cancelClassFn: function () {
						var _this = this;
						this.classDialogVisible = false;
					},

					saveClassCodeFn: function () {

						var _this = this;
						var validate = false;
						_this.$refs.refClassForm.validate(function (valid) {
							validate = valid;
						});
						if (!validate) {
							return;
						}

						let urlparam = "";

						if (_this.isClassaddFlag) {
							urlparam = 'api/use/plats/taskSchedule/saveUseCatalog';
						} else {
							urlparam = 'api/use/plats/taskSchedule/updateUseCatalog';
						}

						yufp.service.request({
							method: 'POST',
							url: urlparam,
							data: _this.$refs.refClassForm.formModel,
							callback: function (code, message, response) {

								if (response.code == 0) {
									_this.$message('操作成功');
									_this.classDialogVisible = false;
									_this.$refs.refTree.remoteData({});
								} else {
									_this.$message(response.message);
								}
							}
						});

					},


					updateTreeFn: function () {
						var _this = this;

						if (_this.currentClickNode.nodeType != 'C') {
							_this.$message({ message: "请选择一个事件目录", type: "warning" });
							return;
						}

						_this.classDialogVisible = true;
						_this.viewClassTitle = _this.viewClassTitleArrry[0];
						// _this.$set( _this.classFields[0].fields[4], 'readonly',  true);
						_this.isClassaddFlag = false;
						_this.classCodeReadOnly = true;
						_this.$nextTick(function () {
							_this.$refs.refClassForm.switch(_this.classFields[0].fields[4].field, 'disabled', true);
							_this.$refs.refClassForm.resetFields();
							_this.$refs.refClassForm.formModel.appCode = _this.currentClickNode.appCode;
							_this.$refs.refClassForm.formModel.appName = _this.currentClickNode.appName;
							_this.$refs.refClassForm.formModel.parentFolder = _this.currentClickNode.parentId;
							_this.$refs.refClassForm.formModel.parentFolderName = _this.currentClickNode.parentName;
							_this.$refs.refClassForm.formModel.folderCode = _this.currentClickNode.currentNodeId;
							_this.$refs.refClassForm.formModel.folderName = _this.currentClickNode.currentNodeName;
							_this.$refs.refClassForm.formModel.remark = _this.currentClickNode.remark;
						});

					},

					deleteTreeFn: function () {
						var _this = this;

						if (_this.currentClickNode.nodeType != 'C') {
							_this.$message({ message: "请选择一个事件目录", type: "warning" });
							return;
						}
						_this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
							confirmButtonText: '确定',
							cancelButtonText: '取消',
							type: 'warning',
							duration: 6000,
							center: true,
							callback: function (action) {
								if (action === 'confirm') {
									let paramObj = {};
									paramObj.appCode = _this.currentClickNode.appCode;
									paramObj.folderCode = _this.currentClickNode.currentNodeId;

									yufp.service.request({
										method: 'DELETE',
										url: "api/use/plats/taskSchedule/deleteUseCatalog",
										data: paramObj,
										callback: function (code, message, response) {
											if (response.code != 0) {
												_this.$message(response.message);
											} else {
												_this.$message('操作成功');
												_this.$refs.refTree.remoteData({});
											}

										}
									});
								}
							}
						});
					},
					/**
					 * 新增
					 */
					addFn: function () {
						var _this = this;
						_this.viewTitle = _this.viewTitleArrry[0];
						_this.addFlag = true;
						_this.updateFlag = false;
						_this.isReadOnly = false;
						_this.dialogVisible = true;
						_this.activeTabName = "taskInfo";
						_this.isView = false;
						_this.setInitrelDataList(_this.currentClickNode.appCode, 'add', {});
					},

					viewDataFn: function (data) {
						var _this = this;
						_this.viewOnly = true;
						_this.nodeTemp.appCode = data.appCode;
						_this.isReadOnly = true;
						_this.viewTitle = _this.viewTitleArrry[2];
						_this.dialogVisible = true;
						_this.addFlag = false;
						_this.updateFlag = true;
						_this.activeTabName = "taskInfo";
						_this.isView = true;
						_this.setInitrelDataList(data.appCode, 'view', data);
					},

					/**
					 * 修改
					 */
					modifyFn: function () {
						var _this = this;
						if (_this.$refs.refTable.selections.length != 1) {
							_this.$message({ message: '请先选择一条记录', type: 'warning',duration: 6000 });
							return;
						}
						_this.nodeTemp.appCode = _this.$refs.refTable.selections[0].appCode;
						_this.isReadOnly = true;
						_this.viewTitle = _this.viewTitleArrry[1];
						_this.dialogVisible = true;
						_this.addFlag = false;
						_this.isView = false;
						_this.updateFlag = true;
						_this.activeTabName = "taskInfo";
						//后台请求
						var dat = _this.$refs.refTable.selections[0];
						var par = {};
						par.appCode = dat.appCode;
						par.groupCode = dat.groupCode;
						yufp.service.request({
						method: 'GET',
						url: 'api/use/plats/taskSchedule/queryList',
						data: {condition: JSON.stringify(par)},
						async: false,
						callback: function (code, message, response) {
								if (response.code != 0) {
									_this.$message(response.message);
								} else {
									_this.setInitrelDataList(response.data[0].appCode, 'update', response.data[0]);
								}
							}
						});
					},
					/**
					 * 删除
					 */
					deleteFn: function () {
						var _this = this;
						var selections = _this.$refs.refTable.selections;
						if (selections.length != 1) {
							_this.$message({ message: '请先选择一条记录', type: 'warning',duration: 6000 });
							return;
						}

						_this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
							confirmButtonText: '确定',
							cancelButtonText: '取消',
							type: 'warning',
							duration: 6000,
							center: true,
							callback: function (action) {
								if (action === 'confirm') {
									yufp.service.request({
										method: 'DELETE',
										url: "api/use/plats/taskSchedule/deleteUseTaskSchedule",
										data: selections[0],
										callback: function (code, message, response) {
											if (response.code != 0) {
												isOk = false;
												_this.$message({ message: response.message, type: "warning" });
											} else {
												_this.reloadData();
												_this.$message('操作成功');
												_this.dialogVisible = false;

											}

										}
									});
								}
							}
						});
					},

					batchSave: function () {
						var _this = this;
						_this.$confirm('此操作将批量保存所有任务记录, 是否继续?', '提示', {
							confirmButtonText: '确定',
							cancelButtonText: '取消',
							type: 'warning',
							duration: 6000,
							center: true,
							callback: function (action) {
								if (action === 'confirm') {
									_this.showLoading();
									yufp.service.request({
										method: 'POST',
										url: "api/citiccard/use/task/batchCreate",
										callback: function (code, message, response) {
											_this.closeLoading();
											if (response.code != 0) {
												isOk = false;
												_this.$message({ message: response.message, type: "warning" });
											} else {
												// _this.reloadData();
												_this.$message({ message: response.message });
												// _this.dialogVisible = false;

											}

										}
									});
								}
							}
						});
					},

					reloadData: function () {
						var _this = this;

						var param = { condition: JSON.stringify(_this.searchFormdata) };
						_this.$refs.refTable.remoteData(param);
					},


					selectFolder: function () {
						var _this = this;
						if (_this.addFlag) {
							_this.folderRoot = _this.currentClickNode.appCode;
						} else {
							_this.folderRoot = _this.$refs.refTable.selections[0].appCode;
						}

						_this.defaultFolderKey.splice(0);
						if (_this.formdata.folderCode != null) {
							_this.defaultFolderKey.push(_this.formdata.folderCode);

						}

						_this.chooseFolderDialogVisible = true;
						_this.$nextTick(function () {
							_this.$refs.refFolderTree.remoteData({});
						});

					},



					selectFolderSaveFn: function () {
						var _this = this;
						var checkObjects = this.$refs.refFolderTree.getCheckedNodes();
						if (checkObjects.length != 1) {
							_this.$message({ message: '请先选择一条记录', type: 'warning',duration: 6000 });
							return;
						} else {
							_this.formdata.folderCode = checkObjects[0].currentNodeId;
							_this.formdata.folderName = checkObjects[0].currentNodeName;
							_this.chooseFolderDialogVisible = false;
						}
					},

					selectFolderCancelFn: function () {
						var _this = this;
						var checkObjects = this.$refs.refFolderTree.getCheckedNodes();
						for (var i = 0; i < checkObjects.length; i++) {
							this.$refs.refFolderTree.setChecked(checkObjects[i], false);
						}

						_this.chooseFolderDialogVisible = false;
					},

					folderNodeClickFn: function (nodeData) {

						var checkObjects = this.$refs.refFolderTree.getCheckedNodes();
						for (var i = 0; i < checkObjects.length; i++) {
							if (nodeData.currentNodeId === checkObjects[i].currentNodeId) {
								continue;
							} else {
								this.$refs.refFolderTree.setChecked(checkObjects[i], false);
							}
						}

					},

					cancelFn: function () {
						var _this = this;
						_this.dialogVisible = false;
					},

					nextStep: function () {
						var _this = this;
						var validate = false;
						_this.$refs.refForm.validate(function (valid) {
							validate = valid;
						});
						if (!validate) {
							return;
						} else {
							if (_this.formdata.effectDate != null) {
								if (_this.formdata.expireDate != null) {
									if ((new Date(_this.formdata.effectDate).getTime()) > (new Date(_this.formdata.expireDate).getTime())) {
										_this.$message({ message: "生效日期不能大于失效日期", type: "warning" });
										return;
									}
								}

							}

							this.activeTabName = "taskParam";
						}

					},

					lastStep: function () {
						this.activeTabName = "taskInfo";
					},
					saveFn: function () {
						
						var _this = this;
						var validate = false;
						_this.$refs.refForm.validate(function (valid) {
							validate = valid;
						});
						if (!validate) {
							return;
						}
						var paramObj = _this.formdata;
						// 结束时间处理
						if (paramObj.expireDate == null) {
							paramObj.expireDate = ' ';
						}
						if (_this.paramDatas.length > 0) {
							var paramCodecheck=[];
							
							for (let i = 0; i < _this.paramDatas.length; i++) {
								
								if (_this.paramDatas[i].paramCode == null || _this.paramDatas[i].paramCode.trim() == ""
									|| _this.paramDatas[i].paramName == null || _this.paramDatas[i].paramName.trim() == ""
									|| _this.paramDatas[i].paramValue == null || _this.paramDatas[i].paramValue.trim() == "") {
									_this.$message({ message: "参数代码，参数名称，参数值均不能为空", type: "warning" });
									return;
								}
								if (paramCodecheck.indexOf(_this.paramDatas[i].paramCode)!=-1) {
									_this.$message({ message: "参数代码"+_this.paramDatas[i].paramCode+"重复,请调整或修改", type: "warning" });
									return;
								}else{						
									paramCodecheck.push(_this.paramDatas[i].paramCode)
								}
							}
							paramObj.useTaskParamList = _this.paramDatas;

						}

						let urlparam = "";
						if (_this.addFlag) {
							paramObj.appCode = _this.currentClickNode.appCode;
							urlparam = 'api/use/plats/taskSchedule/addUseTaskSchedule';
						} else {
							urlparam = 'api/use/plats/taskSchedule/updateUseTaskSchedule';
						}

						yufp.service.request({
							method: 'POST',
							url: urlparam,
							data: paramObj,
							callback: function (code, message, response) {
								if (response.code == 0) {
									_this.reloadData();
									_this.dialogVisible = false;
								} else {
									_this.$message({ message: response.message, type: "error" });
								}
							}
						});
					},

					addParams: function () {

						var _this = this;
						var obj = {
							paramCode: '',
							paramName: '',
							paramValue: '',
							remark: ""
						};
						_this.paramDatas.push(obj);

					},

					deleteParams: function () {
						var _this = this;
						let selectDatas = _this.$refs.refparamstab.selections;
						for (let jdx = _this.paramDatas.length - 1; jdx >= 0; jdx--) {
							for (let idx = 0; selectDatas.length > idx; idx++) {
								if (_this.paramDatas[jdx] == selectDatas[idx]) {
									_this.paramDatas.splice(jdx, 1);
									break;
								}
							}

						}
					},
					taskOn: function () {
						var _this = this;
						if (_this.$refs.refTable.selections.length != 1) {
							_this.$message({ message: '请先选择一条记录', type: 'warning',duration: 6000 });
							return;
						}

						_this.$confirm('此操作将使该任务生效, 是否继续?', '提示', {
							confirmButtonText: '确定',
							cancelButtonText: '取消',
							type: 'warning',
							duration: 6000,
							center: true,
							callback: function (action) {
								if (action === 'confirm') {
									yufp.service.request({
										method: 'POST',
										url: "api/use/plats/taskSchedule/taskOnUseTaskSchedule",
										data: _this.$refs.refTable.selections[0],
										callback: function (code, message, response) {
											if (response.code != 0) {
												isOk = false;
												_this.$message(response.message);
											} else {
												var paramObject = {};

												if (_this.currentClickNode.appCode != null && _this.currentClickNode.appCode != '0000') {
													paramObject.appCode = _this.currentClickNode.appCode;

												}
												var param = { condition: JSON.stringify(paramObject) };
												_this.$refs.refTable.remoteData(param);
												_this.$message('操作成功');
												_this.dialogVisible = false;

											}

										}
									});
								}
							}
						});

					},
					taskOff: function () {
						var _this = this;
						if (_this.$refs.refTable.selections.length != 1) {
							_this.$message({ message: '请先选择一条记录', type: 'warning',duration: 6000 });
							return;
						}
						_this.$confirm('此操作将使该任务失效, 是否继续?', '提示', {
							confirmButtonText: '确定',
							cancelButtonText: '取消',
							type: 'warning',
							duration: 6000,
							center: true,
							callback: function (action) {
								if (action === 'confirm') {
									yufp.service.request({
										method: 'POST',
										url: "api/use/plats/taskSchedule/taskOffUseTaskSchedule",
										data: _this.$refs.refTable.selections[0],
										callback: function (code, message, response) {
											if (response.code != 0) {
												isOk = false;
												_this.$message(response.message);
											} else {
												var paramObject = {};

												if (_this.currentClickNode.appCode != null && _this.currentClickNode.appCode != '0000') {
													paramObject.appCode = _this.currentClickNode.appCode;

												}
												var param = { condition: JSON.stringify(paramObject) };
												_this.$refs.refTable.remoteData(param);
												_this.$message('操作成功');
												_this.dialogVisible = false;

											}

										}
									});
								}
							}
						});


					},


					queryParamList: function (appCode, groupCode) {
						var _this = this;
						var paramObj = {};
						paramObj.appCode = appCode;
						paramObj.groupCode = groupCode;

						yufp.service.request({
							method: 'GET',
							url: "api/use/plats/taskSchedule/queryParamList",
							data: paramObj,
							async: false,
							callback: function (code, message, response) {
								if (response.code != 0) {
									_this.$message(response.message);
								} else {


									for (let i = 0; i < response.data.length; i++) {
										_this.paramDatas.push(response.data[i]);
									}

								}

							}
						});
					},

					changeTaskType: function (val) {
						if (val === 'T') {
							this.isTrigger = true;
							if (this.triggerRules.length == 0) {
								this.triggerRules.push({ required: true, message: '必填项', trigger: 'blur' });
							}

						} else {
							this.isTrigger = false;
							if (this.triggerRules.length > 0) {
								this.triggerRules.splice(0);
							}
						}
					},
					changeGroup: function (vals, vname) { //选择调度任务流后自动带出任务名称
						if (vname !== '') {
							this.formdata.taskName = vname;
						}
					},

					setInitrelDataList: function (appCode, operate, currentData) {
						var _this = this;
						var paramObj = {};
						paramObj.appCode = appCode;

						yufp.service.request({
							method: 'GET',
							url: _this.queryRefDataList,
							data: paramObj,
							async: false,
							callback: function (code, message, response) {
								if (response.code != 0) {
									_this.$message(response.message);
								} else {
									_this.paramDatas.splice(0);
									_this.calendarCodeOptions.splice(0);
									_this.triggerOptions.splice(0);
									_this.groupCodeOptions.splice(0);

									for (let i = 0; i < response.data.triggerList.length; i++) {
										_this.triggerOptions.push({ key: response.data.triggerList[i].timerCode, value: response.data.triggerList[i].timerName });
									}

									for (let i = 0; i < response.data.calendarList.length; i++) {
										_this.calendarCodeOptions.push({ key: response.data.calendarList[i].calendarCode, value: response.data.calendarList[i].calendarName });
									}

									for (let i = 0; i < response.data.wftGrpList.length; i++) {
										_this.groupCodeOptions.push({ key: response.data.wftGrpList[i].groupCode, value: response.data.wftGrpList[i].groupName });
									}

									_this.$nextTick(function () {
										_this.formdata.triggerId = "";
										_this.$refs.refForm.resetFields();
										if (operate != 'add') {
											yufp.extend(_this.formdata, currentData);
											_this.formdata.effectDate = _this.formatStrToDate(currentData.effectDate)// _this.formdata.effectDate.trim() ;
											_this.formdata.expireDate = _this.formatStrToDate(currentData.expireDate);
											_this.queryParamList(currentData.appCode, currentData.groupCode);
											_this.$nextTick(function () {
												_this.formdata.taskName = currentData.taskName;
											})
											// 修改进行内置时点展示
											if (currentData.insideCycleTime) {
												_this.showConfim = false;
												_this.formdata.InSideFlag = "Y";
												_this.formdata.insideCycleTime=currentData.insideCycleTime;
												//_this.formdata.insideCycleTime = _this.formatStrToDate(currentData.insideCycleTime);
											} else {
												_this.formdata.InSideFlag = "N";
											}
										} else {
											_this.formdata.appCode = _this.currentClickNode.appCode;
											_this.formdata.taskType = "T";
											_this.formdata.validFlag = "Y";//默认为启用
											_this.formdata.calendarCode = " ";
											_this.formdata.triggerId = "";
											if (_this.currentClickNode.currentNodeId === _this.currentClickNode.appCode) {
												_this.formdata.folderCode = _this.currentClickNode.currentNodeId;
												_this.formdata.folderName = "应用根目录";
											} else {
												_this.formdata.folderCode = _this.currentClickNode.currentNodeId;
												_this.formdata.folderName = _this.currentClickNode.currentNodeName;
											}
											// 新增默认不适用内置时点
											_this.formdata.InSideFlag = "N";
										}
										// _this.$forceUpdate();
									});
								}
							}
						});
					},

					formatStrToDate: function (strDate) {
						if (strDate != null && strDate.length == 8) {

							var year = parseInt(strDate.substring(0, 4));
							var month = parseInt(strDate.substring(4, 6));
							var day = parseInt(strDate.substring(6, 8));
							return new Date(year, month - 1, day);

						} else {
							return null;
						}
					},


					selectCycleTime: function () {
						var _this = this;
						_this.chooseCommonParamDialogVisible = true;
						_this.$nextTick(function () {
							let model = {};
							if (_this.addFlag) {
								model.appCode = _this.currentClickNode.appCode;
							} else {
								if(_this.viewOnly){
									model.appCode = _this.nodeTemp.appCode;
								}else{
									model.appCode = _this.$refs.refTable.selections[0].appCode;								
								}
							}

							var param = { condition: JSON.stringify(model) };
							_this.$refs.commParamTableRef.remoteData(param);

						});
					},

					selectCommParamValue: function () {
						var _this = this;
						if (_this.$refs.commParamTableRef.selections.length != 1) {
							_this.$message('请先选择一条数据');
							return;
						}

						_this.formdata.cycleTime = "{#" + _this.$refs.commParamTableRef.selections[0].paramCode + "#}";

						_this.chooseCommonParamDialogVisible = false;
					},

					formartDate: function (val) {
						if (val == null) {
							return "";
						}
						var d = new Date(val);
						var year = d.getFullYear();
						var month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1);
						var date = d.getDate() < 10 ? '0' + d.getDate() : d.getDate();

						return year + "" + month + "" + date;
					},
					// 触发器选择页面打开
					selectTrigger: function () {
						var _this = this;
						_this.chooseTriggerDialogVisible = true;
						_this.$nextTick(function () {
							let model = {};
							if (_this.addFlag) {
								model.appCode = _this.currentClickNode.appCode;
							} else {
								model.appCode = _this.$refs.refTable.selections[0].appCode;
							}
							var param = { condition: JSON.stringify(model) };
							_this.$refs.triggerTableRef.remoteData(param);
						});
					},
					// 触发器选择动作
					selectTriggerValue: function () {
						var _this = this;
						if (_this.$refs.triggerTableRef.selections.length != 1) {
							_this.$message('请先选择一条数据');
							return;
						}
						_this.formdata.triggerNm = _this.$refs.triggerTableRef.selections[0].timerName;
						_this.formdata.triggerId = _this.$refs.triggerTableRef.selections[0].timerCode;
						_this.chooseTriggerDialogVisible = false;
					},
				},
			});
		};
	});